package com.cheung.leetcode.normal;

import lyroot.entity.TreeNode;

public class LC98 {

    public static boolean isValidBST(TreeNode root) {
        if (root == null) {
            return true;
        }
        boolean valid = (root.left == null || root.val > root.left.val) && (root.right == null || root.val < root.right.val);
        return valid && isValidBST(root.left) && isValidBST(root.right);
    }

    public static void main(String[] args) {
        TreeNode t1 = new TreeNode(1);
        TreeNode t2 = new TreeNode(2);
        TreeNode t3 = new TreeNode(3);

//        t2.left = t1;
        t2.right = t3;

        System.out.println(isValidBST(t2));
    }
}
